﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace qlvt
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            DataTable dt = HangHoa.DanhSachHangHoa();
            cboHangHoa.ItemsSource = dt.DefaultView;
            cboHangHoa.DisplayMemberPath = "tenhang";
            cboHangHoa.SelectedValuePath = "mahang";
        }

        private void cmdLuu_Click(object sender, RoutedEventArgs e)
        {
            string sohd = txtSoHD.Text;
            string mahang = cboHangHoa.SelectedValue.ToString();
            string dienGiai = txtDienGiai.Text;
            double sl = double.Parse(txtSoLuong.Text);
            double dg = double.Parse(txtDonGia.Text);
            HoaDon.LuuHoaDon(sohd, mahang, sl, dg, dienGiai);
            txtSoHD.Text = "";
            txtDienGiai.Text = "";
            txtSoLuong.Text = "";
            txtDonGia.Text = "";
            cboHangHoa.Text = "";
            txtSoHD.Focus();

        }

        private void cmdThoat_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }
    }
}
